#pragma once
#include "TSSrv_i.h"

class CSqlQueryBuilder
{
public:
	static CSqlQueryBuilder& GetInstance()
	{
		if (m_Instance == NULL)
		{
			m_Instance = new CSqlQueryBuilder();
		}
		return *m_Instance;
	}
   
	~CSqlQueryBuilder(void);

	void Init();
	bool GetSqlString(TsDatastoreItemTypeEnum datastoreItemType, BSTR xmlQuery, _bstr_t& sqlText);
	//bool GetSqlCondition(BSTR xml, _bstr_t& sql);
	//bool GetSqlFragment(_bstr_t column, _bstr_t op, _bstr_t value, _bstr_t& sqlText);


private:
	CSqlQueryBuilder();
	MSXML2::IXMLDOMDocument2Ptr m_spXmlDoc;
    MSXML2::IXMLDOMSchemaCollectionPtr  m_spXS;
    MSXML2::IXMLDOMDocument2Ptr m_spXSLDoc;

	_bstr_t LoadXmlResource(int resId);
	static CSqlQueryBuilder * m_Instance;
};